package org.pearl.account.service;

import com.baomidou.mybatisplus.extension.service.IService;
import io.seata.rm.tcc.api.BusinessActionContext;
import io.seata.rm.tcc.api.BusinessActionContextParameter;
import io.seata.rm.tcc.api.LocalTCC;
import io.seata.rm.tcc.api.TwoPhaseBusinessAction;
import org.pearl.account.entity.AccountTbl;

/**
 * <p>
 * 服务类
 * </p>
 *
 * @author td
 * @since 2020-01-02
 */
@LocalTCC
public interface AccountTblService extends IService<AccountTbl> {

    /**
     * 执行资源检查及预留操作
     */
    @TwoPhaseBusinessAction(name = "prepareBuy", commitMethod = "commit", rollbackMethod = "rollback")
    Object prepareBuy(@BusinessActionContextParameter(paramName = "userId") String userId, @BusinessActionContextParameter(paramName = "code") String code, @BusinessActionContextParameter(paramName = "count") Long count);

    /**
     * 全局事物进行提交
     */
    boolean commit(BusinessActionContext actionContext);

    /**
     * 全局事务进行回滚
     */
    boolean rollback(BusinessActionContext actionContext);
}
